<?php
namespace app\question\controller\admin;
use app\common\controller\Admin;
use app\common\annotation\NodeAnnotation;
use app\common\traits\ControllerCurd;
use app\question\model\QuestionExam;
use app\question\model\QuestionExamSignUser;
use app\question\model\QuestionSubject;
use think\Request;

/**
 * @NodeAnnotation(
 *     title="考试报名用户",
 *     parent="question/admin.index",
 *     is_menu=0,
 *     is_view=0,
 *     auth=1,
 * )
 */
class Examuser extends Admin
{
    use ControllerCurd;
    public $model;
    public function initialize()
    {
        parent::initialize();
        $this->model = new QuestionExamSignUser();
    }

    /**
     * @NodeAnnotation(
     *     title="考试用户",
     *     parent="question/admin.examuser",
     *     MenuRoot="question/admin.index"
     * )
     */
    public function index()
    {
        $this->assign([
            "examUserList" => $this->model->selectPageDatas()
        ]);
        return $this->fetch();
    }

    /**
     * @NodeAnnotation(
     *     title="添加用户",
     *     parent="question/admin.examuser",
     *     MenuRoot="question/admin.index",
     *     is_menu = 0
     * )
     */
    public function addexamuser(Request $request)
    {
        $this->add(url('question/admin.examuser/index'));

        $this->assign([
            "examList" => (new QuestionExam())->field("id,title")->select()
        ]);

        return $this->fetch();
    }

    /**
     * @NodeAnnotation(
     *     title="编辑用户",
     *     parent="question/admin.examuser",
     *     MenuRoot="question/admin.index",
     *     is_menu = 0
     * )
     */
    public function editexamuser(Request $request,$id=0)
    {
        $this->assign([
            "examUser" =>  $this->model->findData($id),
            "examList" => (new QuestionExam())->field("id,title")->select()
        ]);

        $this->edit(url('question/admin.examuser/index'));

        return $this->fetch();
}

    /**
     * @NodeAnnotation(
     *     title="删除用户",
     *     parent="question/admin.examuser",
     *     MenuRoot="question/admin.index",
     *     is_menu = 0
     * )
     */
    public function delexamuser()
    {
        $this->del();
    }
}